﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using WB.Mvc.Forms;

namespace WB.Forms.Tests.ModelFieldGroups
{
	[TestFixture]
	public class ModelFieldGroupStrategyForModelWithOneSubModel
	{
		private Parent model;

		[SetUp]
		public void BeforeEachTest()
		{
			model = new Parent();
		}

		[Test]
		public void ShouldCreateTwoFieldGroups()
		{
			// Arrange
			ModelFieldGroupStrategy strategy = new ModelFieldGroupStrategy();
			
			// Act
			var groups = strategy.Create(model);

			// Assert
			Assert.AreEqual(2, groups.Count());
		}

		[Test]
		public void ShouldPrefixChildModelPropertyWithModelPropertyName()
		{
			// Arrange
			ModelFieldGroupStrategy strategy = new ModelFieldGroupStrategy();

			// Act
			var groups = strategy.Create(model);
			
			// Assert
			Assert.IsTrue(groups.Last().Key.Fields.First().Name.StartsWith("Child_"));
		}
	}
}
